import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SurveyVO, SurveyForm, SurveyQuery } from '@/api/web/survey/types';

/**
 * 查询问卷表单列表
 * @param query
 * @returns {*}
 */

export const listSurvey = (query?: SurveyQuery): AxiosPromise<SurveyVO[]> => {
  return request({
    url: '/web/survey/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询问卷表单详细
 * @param surveyId
 */
export const getSurvey = (surveyId: string | number): AxiosPromise<SurveyVO> => {
  return request({
    url: '/web/survey/' + surveyId,
    method: 'get'
  });
};

/**
 * 新增问卷表单
 * @param data
 */
export const addSurvey = (data: SurveyForm) => {
  return request({
    url: '/web/survey',
    method: 'post',
    data: data
  });
};

/**
 * 修改问卷表单
 * @param data
 */
export const updateSurvey = (data: SurveyForm) => {
  return request({
    url: '/web/survey',
    method: 'put',
    data: data
  });
};

/**
 * 删除问卷表单
 * @param surveyId
 */
export const delSurvey = (surveyId: string | number | Array<string | number>) => {
  return request({
    url: '/web/survey/' + surveyId,
    method: 'delete'
  });
};
